#include <iostream>
#include <deque>
#include <string>

/* using std::cout; */
/* using std::endl; */
/* using std::deque; */
/* using std::string; */
using namespace std;

void test(){
    deque<string> str;

    string word;
    while(cin >> word){
        str.push_back(word);
        for(auto it = str.begin();it!=str.end();++it){
            cout << *it << " ";
        }
        cout << endl;
    }

}

int main()
{
    test();
    return 0;
}

